<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
    <title>后台管理中心</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/global.css">
    <script type="text/javascript" src="/static/layui/layui.js"></script>
</head>
<body>
<form class="layui-form">
    <div class="layui-tab layui-tab-brief main-tab-container" lay-filter="main-tab">
        <ul class="layui-tab-title main-tab-title">
            <div class="main-tab-item">系统设置</div>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item">
                    <label class="layui-form-label">站点名称</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="text" name="siteName" value="${siteName}" lay-verify="" autocomplete="off" placeholder="请输入站点名称" class="layui-input" />
                    </div>
                    <div class="layui-form-mid layui-word-aux">站点名称，将显示在浏览器窗口标题等位置</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">网站logo</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="text" name="logo" value="${siteLogo}" lay-verify="" autocomplete="off" placeholder="" class="layui-input" />
                        <input type="file" name="file" lay-method="post" lay-type="images" lay-ext="" lay-title="图片" class="layui-upload-file" id="logo">
                    </div>
                    <div class="layui-form-mid layui-word-aux">网站logo，将显示在网站前台</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">二维码</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="text" name="qrcode" value="${siteQrcode}" lay-verify="" autocomplete="off" placeholder="" class="layui-input" />
                        <input type="file" name="file" lay-method="post" lay-type="images" lay-ext="" lay-title="图片" class="layui-upload-file" id="qrcode" />
                    </div>
                    <div class="layui-form-mid layui-word-aux">公众号二维码，将显示在网站前台</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">网站根网址</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="text" name="siteUrl" value="${siteUrl}" lay-verify="" autocomplete="off" placeholder="请输入网站根网址" class="layui-input" />
                    </div>
                    <div class="layui-form-mid layui-word-aux">网站 URL，请以http://开头</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">网站备案号</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="text" name="icp" value="${siteIcp}" lay-verify="" autocomplete="off" placeholder="请输入网站备案号" class="layui-input" />
                    </div>
                    <div class="layui-form-mid layui-word-aux">在此输入网站ICP备案号，它将显示在页面底部</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">网站版权信息</label>
                    <div class="layui-input-inline input-custom-width">
                        <textarea name="copyright" lay-verify="" autocomplete="off" placeholder="请输入网站版权信息" class="layui-textarea">${siteCopyright}</textarea>
                    </div>
                    <div class="layui-form-mid layui-word-aux">在此输入网站版权信息，它将显示在页面底部</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">网站是否开启</label>
                    <div class="layui-input-inline input-custom-width">
                        <c:if test="${siteOpen == '0'}">
                            <input type="radio" name="siteStatus" value="1" title="开启" />
                            <input type="radio" name="siteStatus" value="0" title="关闭" checked />
                        </c:if>
                        <c:if test="${siteOpen == '1'}">
                            <input type="radio" name="siteStatus" value="1" title="开启" checked />
                            <input type="radio" name="siteStatus" value="0" title="关闭" />
                        </c:if>
                    </div>
                    <div class="layui-form-mid layui-word-aux">暂时将站点关闭，其他人无法访问，但不影响管理员访问</div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="siteBase">立即提交</button>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
layui.use(['form', 'element', 'upload'], function(){
  var element = layui.element() //Tab的切换功能，切换事件监听等，需要依赖element模块
  ,form = layui.form()
  ,jq = layui.jquery;
  //logo
  layui.upload({
    url: '/upload/image'
    ,elem:'#logo'
    ,before: function(input){
      loading = layer.load(2, {
        shade: [0.2,'#000'] //0.2透明度的白色背景
      });
    }
    ,success: function(res){
      layer.close(loading);
      jq('input[name=logo]').val(res.url);
      layer.msg(res.message, {icon: 1});
    }
  });
  jq('input[name=logo]').hover(function(){
    jq(this).after('<img class="input-img-show" src="'+jq(this).val()+'" >');
  },function(){
    jq(this).next('img').remove();
  });
  //二维码
  layui.upload({
    url: '/upload/image'
    ,elem:'#qrcode'
    ,before: function(input){
      loading = layer.load(2, {
        shade: [0.2,'#000'] //0.2透明度的白色背景
      });
    }
    ,success: function(res){
      layer.close(loading);
      jq('input[name=qrcode]').val(res.url);
      layer.msg(res.message, {icon: 1});
    }
  });
  jq('input[name=qrcode]').hover(function(){
    jq(this).after('<img class="input-img-show" src="'+jq(this).val()+'" >');
  },function(){
    jq(this).next('img').remove();
  });
  //监听提交
  form.on('submit(siteBase)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000'] //0.2透明度的白色背景
    });
    var param = data.field;
    jq.post('/admin/setting/editWebSite',param,function(data){
      if(data.success){
        layer.close(loading);
        layer.msg(data.message, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else {
        layer.close(loading);
        layer.msg(data.message, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
});
</script>
</body>
</html>